#include "joinroomexecutor.h"

JoinRoomExecutor::JoinRoomExecutor(){

}
JoinRoomExecutor::JoinRoomExecutor(Session* s){
    session=s;
}

void JoinRoomExecutor::execute(Para* cmd){
    QBool flag = QBool(false);
    foreach (Para p, cmd->getArgs())
    {
        if (p.getName() == "success")
        {
            if (p.getText() == "TRUE")
                flag=QBool(true);
            else
                flag=QBool(false);
            break;
        }
    }
    foreach (Para p, cmd->getArgs())
    {
        if (flag){
            if (p.getName() == "rule")
            {
                session->setRule(p.getText());
                emit proceed();
                break;
            }
        }else{
            if (p.getName() == "reason")
            {
                emit fail(p.getText());
                break;
            }
        }
    }
}
